package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {
    public static void main(String[] args) {
        Collection a = new ArrayList();
        a.add("我");
        a.add("真");
        a.add("帅");
        a.add("帅");
        System.out.println(a);
        Iterator it = a.iterator();
        while (it.hasNext()){
            String str = (String) it.next();
            System.out.println(str);
            if ("帅".equals(str)){
                it.remove();
            }
        }
        System.out.println(a);
    }
}
